// vue.config.js
// console.log(1)
/**
 * @type {import('@vue/cli-service').ProjectOptions}
 */
module.exports = {
  // 选项...
  chainWebpack: function (config) {
    if (process.env.NODE_ENV === 'production') {
      config.externals({
        'element-ui': 'element-ui',
        'element-ext': 'element-ext',
        'quill': 'quill',
        'echarts': 'echarts',
        'vue-echarts': 'vue-echarts',
        // 'vue-virtual-scroll-list': 'vue-virtual-scroll-list',
        "@vue/composition-api":"@vue/composition-api"
      })
    } else {
      config
        .entry('app')
        .clear()
        .add('./example/main.js')
    }
  },
  // 不需要生产环境的 source map
  productionSourceMap: false,
  configureWebpack: {
    resolve: {
      alias: {
        '@example': '/example'
      }
    },
  },
  css: {
    loaderOptions: {
      sass: {
        implementation: require('sass'), // This line must in sass option
      },
    },
  },
  devServer: {
    inline: false,
    headers: { 'Access-Control-Allow-Origin': '*' },
    proxy: {
      // 字符串简写写法
      // '/api': 'http://192.168.1.51:10010',
      '/api': {
        target: process.env.VUE_APP_API_SEVER,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      },
      '/zy-boot': {
        target: 'http://192.168.1.51:8080/zy-boot/',
        changeOrigin: true,
        pathRewrite: {
          '^/zy-boot': ''
        }
      },
    },
  }
}
